﻿Ext.apply(Kwan, {
    CheckDelete: function (d) {
        if (d.length < 5) { this.showNotify(this.PROMPTEDERR_NOSELECT, this.ERR_NOSELECT); return; }
        else { this.showDeleteAllConfirm(AD, d); }
    },
    CellCommand: function (grid, record, command, rowIndex) {
        //document.write(this.objToString(grid.store.getAt(rowIndex)) + '<br><br>' + this.objToString(record));
        //if (grid.store.getAt(rowIndex) === record) { document.write(grid.store.getAt(rowIndex).data.id) }
        switch (command) {
            case "Edit": AD.EditInfo(record.data.id); break;
            case "Delete": this.showDeleteConfirm(AD, record.data.id); break;
            default: AD.ChangeState(record.data.id, command); break;
        }
    },
    updateTree: function (treePanel, command) {
        //document.write(Kwan.objToString()).get('id')
        var id = treePanel.getSelectionModel().getSelectedNode().id;
        switch (command) {
            case "Rename": AD.SetClassInfo(id); break;
            case "Remove": treePanel.removeNode(treePanel.menuNode); break;
            default: AD.InitClassInfo(id); break;
        }
    },
    addTreeNode: function (treePanel) {
        AD.InitClassInfo(id);
    },
    showMenu: function (node, e) {
        var menu = TreeContextMenu;
        if (node.browserEvent) {
            this.menuNode = this.getRootNode();
            menu.nodeName = "";
            this.getSelectionModel().clearSelections();
            e = node;
        }
        else {
            this.menuNode = node;
            menu.nodeName = node.text;
            node.select();
        }

        menu.showAt([e.getXY()[0], e.getXY()[1] + 18]);
        e.stopEvent();
    }
});